From: David Härdeman Date: Sun, 5 Oct 2025 06:50:30 +0000 (+0200) Subject: luci-mod-network: add initial support for multi-DUIDs X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22/%22https:/collectd.org/%22?a=commitdiff_plain;h=5c1d12a07968aab26c87ca9ec3659f694a6f1a75;p=project%2Fluci.git luci-mod-network: add initial support for multi-DUIDs And also add support/validation for DUID%IAID values. Signed-off-by: David Härdeman --- diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index 0c804f9bfb..14ae192cb0 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -158,6 +158,24 @@ function validateHostname(sid, s) { return true; } +function validateDUIDIAID(sid, s) { + if (s == null || s == '') + return true; + + var parts = s.split('%'); + if (parts.length > 2) + return _('Expecting: %s').format(_('maximum one "%"')); + + // DUID_MAX_LEN = 130 => 260 hex chars + if (parts[0].length < 20 || parts[0].length > 260 || !parts[0].match(/^([a-f0-9]{2})+$/i)) + return _('Expecting: %s').format(_('DUID with an even number (20 to 260) of hexadecimal characters')); + + if (parts.length == 2 && (parts[1].length < 1 || parts[1].length > 8 || !parts[1].match(/^[a-f0-9]+$/i))) + return _('Expecting: %s').format(_('IAID of 1 to 8 hexadecimal characters')); + + return true; +}; + function expandAndFormatMAC(macs) { let result = []; @@ -849,10 +867,13 @@ return view.extend({ so.value('7d', _('7d (7 days)')); so.value('infinite', _('infinite (lease does not expire)')); - so = ss.option(form.Value, 'duid', - _('DUID'), - _('The DHCPv6-DUID (DHCP unique identifier) of this host.')); - so.datatype = 'and(rangelength(20,36),hexstring)'; + so = ss.option(form.DynamicList, 'duid', + _('DUID/IAIDs'), + _('The DHCPv6-DUIDs and, optionally, IAIDs of this host.') + '

' + + _('The same IPv6 addresses will be (re)assigned to any host using one of the DUID or DUID%IAID values listed above. Only one is expected to be in active use on the network at any given time.') + '

' + + _('Syntax: <DUID-hex-str> or <DUID-hex-str>%<IAID-hex-str>')); + so.rmempty = true; + so.validate = validateDUIDIAID; Object.keys(duids).forEach(function(duid) { so.value(duid, '%s (%s)'.format(duid, duids[duid].hostname || duids[duid].macaddr || duids[duid].ip6addr || '?')); });